Added new API service with GET and POST methods#20
Open
Sebastianfiet wants to merge 1 commit intoandy89923:mainfrom
Open
Added new API service with GET and POST methods#20Sebastianfiet wants to merge 1 commit intoandy89923:mainfrom
Sebastianfiet wants to merge 1 commit intoandy89923:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This Pull Request adds a new API service to the nf-example repository. The service includes two HTTP methods: GET and POST.
Details of Changes
Created a new API service:
Added a GET method at /myservice/hello which returns a welcome message.
Added a POST method at /myservice/data that accepts a JSON payload with name and status, processes the data, and returns a confirmation message.
Code Modifications:
router.go: Modified to register the new routes for the GET and POST methods.
nfcfg.yaml: Updated service binding configurations to ensure proper setup for the new API.
New service logic: Created in the relevant service and API files for handling incoming GET and POST requests.
Testing
GET Method: Successfully tested the GET method by sending a request to http://127.0.0.1:8000/myservice/hello, which returned the expected welcome message.
POST Method: Tested the POST method using curl and PowerShell, sending a JSON payload with name and status, and confirmed the response was correct with status 200 OK and the expected output.
Impact
This update introduces a simple API service for testing and future use cases.
It provides a foundation for adding more services in the future if needed.
Notes
The implementation is intended for testing purposes and is based on the structure of the existing codebase.
The POST method processes basic data and responds with the received values for confirmation.